package com.example.moshudriver.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.BeeFramework.Utils.TimeUtil;
import com.sgr.dykdriver.R;
import com.example.moshudriver.protocol.WITHDRAW_ORDER;
import com.nostra13.universalimageloader.core.ImageLoader;

public class MyIncometAdapter extends BaseAdapter {
	protected ImageLoader mImageLoader = ImageLoader.getInstance();
	public  ArrayList<WITHDRAW_ORDER> publicList;
	private Context mContext;
	private LayoutInflater mInflater;
	public MyIncometAdapter(Context context, ArrayList orderList) {
		this.mContext = context;
	this.	publicList=orderList;
	mInflater = LayoutInflater.from(context);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return publicList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		E0_OrderCellHolder holder;
		if(convertView == null) {
			holder = new E0_OrderCellHolder();
			
			convertView =  mInflater.inflate(R.layout.myincome_cell, null);
			
			holder.mycome_category = (TextView) convertView
					.findViewById(R.id.mycome_category);
			holder.myincome_money = (TextView) convertView.findViewById(R.id.myincome_money);
			holder.myincome_time = (TextView) convertView
					.findViewById(R.id.myincome_time);
			holder.myincome_state = (TextView) convertView.findViewById(R.id.myincome_state);
			convertView.setTag(holder);
		} else {
			holder = (E0_OrderCellHolder) convertView.getTag();
		}
	WITHDRAW_ORDER myincome = (WITHDRAW_ORDER) publicList.get(position);
		

		if (myincome != null) {
			holder.myincome_money.setText(myincome.amount+"元");
			holder.myincome_time.setText(TimeUtil.timeFormat( myincome.created_at));
//			holder.myincome_time.setText(TimeUtil.timeAgo( myincome.created_at));
			
			if (myincome.category == 6) {//合伙人基本工资
				holder.mycome_category.setText("合伙人工资");
			}else if(myincome.category == 3){//提成
				holder.mycome_category.setText("提成");
			}else if(myincome.category == 0){
				holder.myincome_state.setVisibility(View.VISIBLE);
				if(myincome.state==1){
					holder.myincome_state.setText("提现成功");
				}else if(myincome.state==0){
					holder.myincome_state.setText("提现中");
				}else{
					holder.myincome_state.setText("提现失败");
				}
				holder.mycome_category.setText("提现");
			}else if(myincome.category == 5){
				holder.mycome_category.setText("充值");
			}
			else if(myincome.category == 4){
				holder.mycome_category.setText("收入");
			}
			else if(myincome.category == 7){
				holder.mycome_category.setText("消费");
			}
			
			
		}
		return  convertView;
	}

	public class E0_OrderCellHolder  {
	 TextView mycome_category;
		 TextView myincome_money;
		TextView myincome_time;
		TextView myincome_state;
		
	
	}

	
}
